package com.ssl.springframework.beans.factory;

import com.ssl.springframework.beans.factory.config.BeanDefinition;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 描述：Bean工厂
 *
 * @author ssl
 * @create 2021/6/10 0010.
 */
public class BeanFactory {
    // 存放 Bean定义的容器
    private Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<>();


    /**
     * 获取 Bean定义
     * @param beanName
     * @return
     */
    public Object getBean(String beanName) {
        return beanDefinitionMap.get(beanName).getBean();
    }

    public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) {
        beanDefinitionMap.put(beanName, beanDefinition);
    }
}
